Blitz (459/640)

From:Sami N��t�nen
Date:17 Sep 99 at 11:17:48
Subject:Re: Readfile

On 17-Sep-99, Bippy M wrote.

> Hiya Guys,
>
> okay I need to edit a file using a patch file.. now the file I'm editing
> is 35Mb(ish) and I only have 18Mb mem would readfile handle this? If not
> how do I get around this problem?
>
> Also The patch format is 4byte offset, 1byte for num bytes to patch and
> then num bytes for patch eg..
>
> xxxx,y,zzzz xxxx=offset in file, y=number of bytes to patch zzzz is the
> patched data (Which is equal num of bytes to z) so..
>
> 001fd83a0523fe0eacd4
>
> would translate to
>
> File offset = 001fd83a
> bytes to patch = 05
> patch data = 23 fe 0e ac d4
>
> how would I get this info from the patch (Remember the patch /could/ be
> bigger than mem!!).. and also remember z could equal a max of 255!!!
>
> Cheers

well here it is, but I think you have to modify it a litle.

buf.l=AllocMem(256,$10000) ; buffer for read/write actions
If buf=0 Then End ; if not get then exit

If OpenFile(1,"filuname") ; try to open file for patching
If ReadFile(2,"patchname") ; try to open patch file

; you may want to add here some checkings that this really is suitable
; patch for this file!!!!
; one way could be that patch file would contain say 4 byte offset to the
; file which is going to be patched and then 256 bytes of data from that
; location. so that you can compare if this patch file really belongs to
; this file.
; or maybe the best thing would be to use ID string in the file which you
; are patching and after patch you would write new one. CRC would be best,
; but it will take very long to count CRC for such big files like yours.

offset.l=0 ; init offset
count.w=0 ; init count
While Eof(2)=0 ; while not end of patch file
ReadMem 2,&offset,4 ; read next patching offset
ReadMem 2,&count+1,1 ; and how many bytes we patch
ReadMem 2,buf,count ; read the patch data
FileSeek 1,offset ; seek to right position
WriteMem 1,buf,count ; and write the patced data
Wend ; and loop back
CloseFile 2 ; close the patchfile
EndIf
CloseFile 1 ; and the data file
EndIf

FreeMem buf,256 ; free the reading buffer



Sami N��t�nen
EMail: sami.naatanen@dlc.fi

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie